

$("#j-shiyan").hover(function () {
    $("#j-shiyan").attr("fill", "#e88736");
}, function () {
    $("#j-shiyan").attr("fill", "#ec9b57");
}, function () {
    alert("haha");
});
// wait until all the resources are loaded
window.addEventListener("load", findSVGElements, false);

function setup(document) {
    //do something with svg document
    var domain = new Array("十堰市", "神农架林区", "襄樊市", "随州市", "孝感市", "黄冈市", "恩施土家族苗族自治区", "宜昌市", "荆门市", "武汉市", "天门市", "潜江市", "仙桃市", "鄂州市", "荆州市", "咸宁市", "黄石市");//定义地区数组
    var bridgeNum = new Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
    var Allpath = document.getElementsByTagName("path");//获取所有的path
    var Alltext = document.getElementsByTagName("text");//获取所有text
    for (var i = 0; i < Allpath.length; i++) {
        //操作所有的区域,使用闭包保存变量i
        (function (arg) {
            Allpath[i].onmouseover = function () {
                this.style.fill = "#59d05d";
                //修改对应的文字
                Alltext[arg].textContent = domain[arg] + "桥总数:" + bridgeNum[arg];
                Alltext[arg].style.fontsize = 20;
                //修改字体并修改数字
                //console.log(arg);
            };
            Allpath[i].onmouseout = function () {
                this.style.fill = "#CCCCCC"
                Alltext[arg].textContent = domain[arg];
                Alltext[arg].style.fontsize = 14;
            }
        })(i);
    }
    //console.log(Allpath);
}

function getSubDocument(embedding_element) {
    if (embedding_element.contentDocument) {
        return embedding_element.contentDocument;
    }
    else {
        var subdoc = null;
        try {
            subdoc = embedding_element.getSVGDocument();
        } catch (e) {
        }
        return subdoc;
    }
}

function findSVGElements() {
    setup(getSubDocument(document.getElementById("hbmap")));//do something with svg
}
